﻿
#region Usings
using System;
using System.Security.Cryptography;
#endregion

namespace LongNet.Security
{
    /// <summary>
    /// Utility class for doing SHA1 hashes
    /// </summary>
    public static class SHA1
    {
        #region Public Static Functions

        /// <summary>
        /// Computes a hash using SHA1
        /// </summary>
        /// <param name="Input">Input string</param>
        /// <returns>A hash of the input string using SHA1</returns>
        public static string ComputeHash(string Input)
        {
            SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
            byte[] InputArray = System.Text.Encoding.ASCII.GetBytes(Input);
            byte[] HashedArray = SHA1.ComputeHash(InputArray);
            SHA1.Clear();
            return BitConverter.ToString(HashedArray).Replace("-", "");
        }

        #endregion
    }
}
